package week03.robotman;

import week03.robotman.pro.Robotman;

/**
 * Created by zhangxiaokun on 2018/2/8.
 */
public class Director {
    private RobotmanBuilder robotmanBuilder ;

    public Director(){}
    public Director(RobotmanBuilder robotmanBuilder){
        this.robotmanBuilder = robotmanBuilder;
    }

    public RobotmanBuilder getRobotmanBuilder() {
        return robotmanBuilder;
    }

    public void setRobotmanBuilder(RobotmanBuilder robotmanBuilder) {
        this.robotmanBuilder = robotmanBuilder;
    }

    public Robotman getRobotman(){
        robotmanBuilder.buildHead();
        robotmanBuilder.buildBody();
        robotmanBuilder.buildHand();
        robotmanBuilder.buildLeg();
        return robotmanBuilder.combineResult();
    }

    public static void main(String[] args) {
        Director director = new Director();
        //跑路机器人
        director.setRobotmanBuilder(new RunRobotmanBuilder());
        Robotman robotman = director.getRobotman();
        System.out.println(robotman);

        //走路机器人
        director.setRobotmanBuilder(new WalkRobotmanBuilder());
        Robotman robotman2 = director.getRobotman();
        System.out.println(robotman2);
    }

}
